#ifndef _PROCESSOR_HPP_20120513
#define _PROCESSOR_HPP_20120513

#include "base.hpp"

#include "connection.hpp"
#include "abstract_processor.hpp"

using namespace mina;

class Processor : public AbstractProcessor
{
	public :
		typedef __gnu_cxx::hash_map<uint64_t, Connection *> ConnMap;
		typedef ConnMap::iterator ConnMap_Iter;

	public :
		void accept_connect(Connection & conn) 
		{
			// LOG4CPLUS_WARN(logger, "connected. ip: " << conn.sock_addr().dot_addr());
			assert(_conn_map.insert(std::make_pair(conn.conn_id()._cid, &conn)).second);
		}

		void remove_connect(Connection & conn) 
		{
			// LOG4CPLUS_WARN(logger, "disconnected. ip: " << conn.sock_addr().dot_addr());
			assert(1 == _conn_map.erase(conn.conn_id()._cid));
		}

		void process_message(Connection & conn, void * data);

	private :
		template <typename _Protocol>
		void process(Connection & conn, const _Protocol & protocol)
		{
			assert(false);
		}

	public :
		ConnMap _conn_map;

		DECL_LOGGER(logger);
};

#endif

